home *** CD-ROM | disk | FTP | other *** search
/ CD World Haziran 1997 / CD World Haziran 1997.iso / Explorer Yardimcilari / PiXCL Tools / Forwhile.px_ / Forwhile.px
Encoding:
PiXCL source  |  1996-07-25  |  3.6 KB  |  178 lines

  1. Initialize:
  2.     WinGetActive(Win$)
  3.     UseCoordinates(PIXEL)
  4.     UseBackGround(TRANSPARENT,192,192,192)
  5.     DrawBackGround
  6.     WaitInput(100)  {let NT and 95 catch up}
  7.     InfoMenu(REMOVE)
  8.     SetMenu()
  9.     WinLocate(Win$,250,10,620,240,Res) 
  10.     Title$ = "For and While Loops"
  11.     WinTitle(Win$, Title$)
  12.     {WinShow(Title$,NOTOPMOST,Res)}
  13.     DirGet(SourceDir$)
  14.  
  15.  
  16.     SetMenu("E&xit!",Leave,
  17.         ENDPOPUP,
  18.         "&FOR Loops",IGNORE,
  19.         "&Programmed FOR",ProgramFor,
  20.         "&Structured FOR",ConstructFor,
  21.         ENDPOPUP,
  22.         "&WHILE Loops",IGNORE,
  23.         "&Programmed WHILE",ProgramWhile,
  24.         "&Structured WHILE",ConstructWhile,
  25.         ENDPOPUP,
  26.         "For-&If-While",ForIfWhile,
  27.         ENDPOPUP,
  28.         "&Help",IGNORE,
  29.         "&Concept",Concept,
  30.         "&View Source",ViewSource,
  31.         "&About",About,
  32.         ENDPOPUP)
  33.         
  34. Wait_for_Input:
  35.     WaitInput()
  36.  
  37.  
  38. Leave:
  39.     End
  40.  
  41. Concept:
  42.     MessageBox(OK,1,INFORMATION,
  43. "This sample program demonstrates the two 
  44. available methods of programming FOR and 
  45. WHILE loops, using firstly:
  46.     Labels and 'Goto' statements;
  47. and secondly:
  48.     Structured FOR and WHILE
  49.     Keywords.
  50.  
  51. Look in the sources to see the differences.",
  52.     "Structured Program controls",Res)
  53.     Goto Wait_for_Input
  54.  
  55. ViewSource:
  56.     PXLFile$ = SourceDir$ + "\forwhile.pxl"
  57.     CmdLine$ = "NotePad " + PXLFile$
  58.     Run(CmdLine$)
  59.     Goto Wait_for_Input
  60.  
  61.  
  62. About:
  63.     AboutUser("Structured Program Loops with PiXCL 4.0",
  64. "FOR - NEXT and WHILE - ENDWHILE structures in PiXCL",
  65. "Sample PiXCL 4.0 program showing variety of built in icons drawn in the client area, depending on the loop parameters")
  66.     Goto Wait_for_Input
  67.  
  68.  
  69. ProgramFor:
  70.     Count = 0
  71.     DrawBackGround
  72. For_Loop:
  73.     DrawIcon( 1,1,0,0,ICON01)
  74.     DrawIcon(41,1,0,0,ICON02)
  75.     DrawIcon(81,1,0,0,ICON03)
  76.     Count++
  77.     Break
  78.     If Count <= 200 Then Goto For_Loop
  79.     DrawText(10,50,"Programmed For Loop complete")
  80.     Goto Wait_for_Input
  81.  
  82.  
  83. ConstructFor:
  84.     DrawBackGround
  85.     For Count = 0 To 100 By 2
  86.         DrawIcon( 1,1,0,0,ICON01)
  87.         DrawIcon(41,1,0,0,ICON02)
  88.         {If Count > 40 Then DrawIcon( 1,1,64,64,ICON11) Break}
  89.         DrawIcon(81,1,0,0,ICON03)
  90.     Next
  91.         DrawNumber(150,20,Count)
  92.  
  93.     LastCount = 100
  94.     Increment = 2
  95.     Zero = 0
  96.     Counter = 0
  97.     For Count = Zero To LastCount By Increment
  98.         DrawIcon( 1,41,0,0,ICON04)
  99.         DrawIcon(41,41,0,0,ICON05)
  100.        {If Count > 40 Then DrawIcon( 1,41,64,64,ICON11) Break}
  101.         DrawIcon(81,41,0,0,ICON06)
  102.         Counter += Increment
  103.     Next
  104.         DrawNumber(150,50,Counter)
  105.  
  106.  
  107.  
  108.     DrawText(10,80,"Structured For Loop complete.")
  109.     Goto Wait_for_Input
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. ProgramWhile:
  117.     Count = 0
  118.     DrawBackGround
  119. While_Loop:
  120.     If Count > 100 Then Goto While_End
  121.         DrawIcon( 1,1,0,0,ICON04)
  122.         DrawIcon(41,1,0,0,ICON05)
  123.         DrawIcon(81,1,0,0,ICON06)
  124.         Count++
  125.     Goto While_Loop
  126. While_End:
  127.     DrawText(10,50,"Programmed While Loop complete.")
  128.     Goto Wait_for_Input
  129.  
  130.  
  131.  
  132.  
  133.  
  134. ConstructWhile:
  135.     Count = 0
  136.     DrawBackGround
  137.     While Count <= 100
  138.         DrawIcon( 1,1,0,0,ICON04)
  139.         DrawIcon(41,1,0,0,ICON05)
  140.         DrawIcon(81,1,0,0,ICON06)
  141.         If Count > 50 Then DrawIcon( 1,41,0,0,ICON11) Break
  142.         Count++
  143.     EndWhile
  144.     DrawNumber(150,20,Count)    
  145.  
  146.     Count$ = "A"  Count = 0
  147.     While Count$ = "A"
  148.         DrawIcon( 1,41,0,0,ICON07)
  149.         DrawIcon(41,41,0,0,ICON08)
  150.         DrawIcon(81,41,0,0,ICON09)
  151.         If Count > 50 Then Count$ = "B"
  152.         Count++
  153.     EndWhile
  154.     DrawNumber(150,50,Count)    
  155.     DrawText(10,80,"Structured While Loop complete.")
  156.  
  157.     Goto Wait_for_Input
  158.  
  159. ForIfWhile:
  160.     DrawBackground
  161.     For A = 0 To 10
  162.        C = A
  163.         While C < 10
  164.             If A < 5 
  165.             DrawIcon(1,1,0,0,ICON01)
  166.             Else
  167.             DrawIcon(1,1,0,0,ICON10)
  168.         Endif
  169.             C++
  170.         EndWhile
  171.     Next
  172.  
  173.     Goto Wait_for_Input
  174.  
  175.  
  176.  
  177.  
  178.